/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package myfilechooser;

import java.awt.Image;
import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 *
 * @author sochy
 */
public class MagicImage {
    
    public static Icon image(String path, int w, int h){
        
        
        // get imageIcon from path
        ImageIcon ii = new ImageIcon(path);
        // get Image object from ImageIcon object
        Image i = ii.getImage();
        // Scale or set image size
        Image img = i.getScaledInstance(w, h, java.awt.Image.SCALE_SMOOTH);
        // Create icon object
        Icon icon = new ImageIcon(img);
        return icon;
    }
    
}
